#ifndef RTSPDEVICE_H
#define RTSPDEVICE_H

#include <QObject>
#include <Windows.h>
#include <QtCore>
#include <string>
#include "imagefifo.h"

//wil
#include <opencv2/opencv.hpp>
#include <iostream>
using namespace std;
using namespace cv;

class RtspDevice : public QObject
{
	Q_OBJECT

public:
	RtspDevice(QObject *parent);
	RtspDevice::RtspDevice();
	~RtspDevice();

	bool openDevice(HANDLE hnd);
	void closeDevice();
	void setDataSavingSpace(UCHAR **data, int size);
	void enableReceving();
	void disableReceving();

	void recvRtspData(int timeout);
	void setWidth(int width);
	void setHeight(int height);
	int getWidth();
	int getHeight();
	void setRtspUrl(string url);

signals:
	//void completeFrameTransmission(unsigned char *data);
	void completeFrameTransmission();
	//void changeResolutionDone();

	public slots:
	void recvRtspData();

private:
	int m_height;
	int m_width;

	string m_url;
	VideoCapture m_cap;

	int m_fifoSize;
	UCHAR **m_dataBuffer;

	int m_curBufId;
	ImageData *m_imageBuffer;
	volatile bool m_recevingFlag;

	QMutex m_mutex;
};

#endif // RTSPDEVICE_H
